import request from "@/utils/request";
import { ArchivesForm, ArchivesPageQuery, ArchivesPageVO } from "@/api/system/archives";
import { ProjectPageQuery, ProjectPageVO } from "@/api/system/project";
import { DictDataPageQuery, DictDataPageVO } from "@/api/system/dict-data";
const BLOG_BASE_URL = "/api/v1/blog";

const BlogAPI = {
  /** 获取博客文章分页数据 */
  getArchivesPage(queryParams?: ArchivesPageQuery) {
    return request<any, PageResult<ArchivesPageVO[]>>({
      url: `${BLOG_BASE_URL}/archives`,
      method: "get",
      params: queryParams,
    });
  },
  /** 获取项目实践分页数据 */
  getProjectsPage(queryParams?: ProjectPageQuery) {
    return request<any, PageResult<ProjectPageVO[]>>({
      url: `${BLOG_BASE_URL}/projects`,
      method: "get",
      params: queryParams,
    });
  },
  /**
   * 获取字典分页列表
   *
   * @param queryParams 查询参数
   * @returns 字典分页结果
   */
  getCategoriesPage(queryParams: DictDataPageQuery) {
    return request<any, PageResult<DictDataPageVO[]>>({
      url: `${BLOG_BASE_URL}/categories`,
      method: "get",
      params: queryParams,
    });
  },

  /**
   * 获取博客文章TOP3
   */
  getTop3() {
    return request<any, PageResult<ArchivesForm[]>>({
      url: `${BLOG_BASE_URL}/top3`,
      method: "get",
    });
  },

  getArchiveById(aid: number) {
    return request<any, ArchivesPageVO>({
      url: `${BLOG_BASE_URL}/getArchivesById/${aid}`,
      method: "get",
    });
  },
};

export default BlogAPI;
